#!python3
# -*- coding: utf-8 -*-

from flask_website.controller.aeWin32 import  AeWin32
import re,json,requests,pymongo,time

from bson import json_util
from bson.objectid import ObjectId
# 配置文件
from flask_website.rounter.config import SKConfig


class mDb():

    myclient = ''

    def __init__(self):
        print('操作mangodb数据库')
        myclient = pymongo.MongoClient(SKConfig.open_sk_primary) # local 2
        self.myclient = myclient

    # 查询数据库数据 
    def update_reads_bydb(self, mongo_table):
        print("查询数据库数据")
        myclient = pymongo.MongoClient(SKConfig.open_sk_primary) # local 2
        dblist = myclient.list_database_names()
        dbname = myclient['haicaov110']
        collection = dbname['infor_articles']
        if(data_list[1] == ''):
            data_list[1] = '0'
        condition = {'_id': ObjectId(wxid)}
        onearticle = {
        'reads' : data_list[0],
        'follow' : data_list[1]}
        result = collection.update_one(condition, {'$set': onearticle})
        print('修改服务器数据:')
        print(result)


